<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- 视窗 -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<link href="/resource/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="/resource/jquery-3.2.1.js"></script>
<script type="text/javascript">
$(function(){
	$.get(
	"/brands",
	function(br){
		for (var i in br) {
			$("#brand").append("<option value='"+br[i].id+"'>"+br[i].name+"</option>")
		}
		$("#brand").val('${goods.brandId}');
	}
	)
	$.get(
	"/types",
	function(ty){
		for (var i in ty) {
			$("#type").append("<option value='"+ty[i].id+"'>"+ty[i].name+"</option>")
		}
		$("#type").val('${goods.typeId}');
	}
	
	)
})
function add(){
	var formData=new FormData($("#form1")[0]);
	$.ajax({
		type:"post",
		url:"/update",
		data:formData,
		processData:false,
		contentType:false,
		success:function(flag){
			  if(flag){
				  alert("修改成功");
				  location="/list"
			  }else{
				  alert("修改失败")
			  }
		}
	})
}
</script>
</head>

<body>
<form id="form1">
<input type="hidden" name="id" value="${goods.id }">
 商品名称：<input type="text" name="name" value="${goods.name }"><br>
 英文名称：<input type="text" name="ename" value="${goods.ename }"><br>
 多钱：<input type="text" name="price" value="${goods.price }"><br>
 剩余：<input type="text" name="store" value="${goods.store }"><br>
描述：<input type="text" name="tag" value="${goods.tag }"><br>
 品牌：<select id="brand" name="brandId"></select><br>
 种类：<select id="type" name="typeId"></select><br>
 尺寸：<input type="text" name="size" value="${goods.size }"><br>
 图片：<input type="file" name="myFile" >
 <img  style="width: 200px; height: 180px"alt="失效" src="/pic/${goods.picture}">
 <br>
 
 <button type="button" onclick="add()">修改</button>

</form>
</body>
</html>